package com.example.speeddating.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.speeddating.entity.Feedback;
import com.example.speeddating.entity.Report;
import com.example.speeddating.mapper.ReportMapper;
import com.example.speeddating.service.ReportService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author tina
 * @since 2023-06-28 11:14:34
 */
@Service
public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> implements ReportService {

    @Autowired
    private ReportMapper reportMapper;

    @Override
    public Page<Report> selectAllReport(int pageNum, int pageSize) {
        Page<Report> reportPage = new Page<>();
        return reportMapper.selectAllReport(reportPage);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void handleFeedback(Long id) {
        Report report = new Report();
        report.setId(id);
        report.setHandle(1);
        reportMapper.updateById(report);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void deleteFeedback(Long id) {
        reportMapper.deleteById(id);
    }
}
